<template>
  <div>
    <el-container style="height: 100%">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu :default-openeds="['1', '3']">
          <el-submenu index="1">
            <template v-slot:title><i class="el-icon-message"></i>导航一</template>
            <el-menu-item-group>
              <template v-slot:title>分组一</template>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-2">选项2</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分组2">
              <el-menu-item index="1-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="1-4">
              <template v-slot:title>选项4</template>
              <el-menu-item index="1-4-1">选项4-1</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-submenu index="2">
            <template v-slot:title><i class="el-icon-menu"></i>导航二</template>
            <el-menu-item-group>
              <template v-slot:title>分组一</template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分组2">
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="2-4">
              <template v-slot:title>选项4</template>
              <el-menu-item index="2-4-1">选项4-1</el-menu-item>
            </el-submenu>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container >
        <el-header style="text-align: right; font-size: 12px">
          <el-dropdown>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu>
              <el-dropdown-item>查看</el-dropdown-item>
              <el-dropdown-item>新增</el-dropdown-item>
              <el-dropdown-item>删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>王小虎</span>
        </el-header>

        <el-main style="height: 100%">
          <el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search"></el-input>
          <el-button type="primary">搜索</el-button>
          &ensp;&ensp;
          <el-input style="width: 200px" placeholder="请输入地址" suffix-icon="el-icon-position"></el-input>
          <el-button type="primary">搜索</el-button>
          <el-table :data="tableData" border stripe>
            <el-table-column prop="id" label="编号" width="140">
            </el-table-column>
            <el-table-column prop="username" label="姓名" width="120">
            </el-table-column>
            <el-table-column prop="phone" label="电话">
            </el-table-column>
            <el-table-column label="操作">
              <el-button type="success">编辑<i class="el-icon-edit"></i></el-button>
              <el-button type="danger">删除<i class="el-icon-remove-outline"></i></el-button>
            </el-table-column>
          </el-table>
          <br/>
          <el-pagination
              :current-page=pageNum
              :page-sizes="[2, 3, 4, 5]"
              :page-size=pageSize
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
          >
          </el-pagination>
        </el-main>
      </el-container>
    </el-container>

  </div>
</template>
<script>
const axios=require('axios');
export default {
  name: "Demo",
  created() {
   this.load();
  },
  methods:{
    load(){
      axios.get("http://localhost:9090/user/page?pageNum="+this.pageNum+"&pageSize="+this.pageSize).then(resp=>{
        this.tableData=resp.data.data;
        this.total=resp.data.total;
      });
    },
    handleCurrentChange(pageNum){
      this.pageNum=pageNum;
      this.load()
    },
    handleSizeChange(pageSize){
      this.pageSize=pageSize;
      this.load();
    },
  },
  data() {
    return {
      tableData:[],
      total: 0,
      pageNum:4,
      pageSize:2,
    }
  }
}
</script>

<style>
.el-header {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}
.el-aside {
  color: #333;
}
</style>